<style type="text/css">
.form-display-as-box{
	width: 108px;
	/*text-align: right;*/
}
#field-password,#field-confirm_password,#field-nip,#field-id_group{
	width:200px !important;
}
#field-nama_lengkap{
	width: 250px;
}
.flexigrid div.form-div{
	margin: 0 auto;
    padding: 16px 0 0;
    width: 426px;
}
.flexigrid.crud-form {
    margin-left: auto !important;
    margin-right: auto !important;
    width: 500px !important;
}

.username-watermark {
 /*   border: 1px solid #dedede;*/
    height: 26px;
    margin-left: 115px;
    margin-top: -1px;
    position: absolute;
    width: 222px;
}
#field-status{
	width: 50px !important;
}
.report-div.success a{
	display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	var change_password = <?php echo json_encode($change_password);?>;

	if(change_password)
	{
		$('#status_field_box').hide();
		$('#id_group_field_box').hide();
		$('.g-output').css('background','#f2f2e9');
		$('.flexigrid.crud-form.edit.pengguna ').before('<h2 style="text-transform:uppercase;padding:.2em 7px;background:#fff;border:solid 1px #ccc"><i class="fa fa-key"></i>&nbsp;Ganti Password</h2>')
	}
	// var newSaveBtn = $('<button id="save-and-go-back-button" class="fm-button btn-large"><i class="fa fa-user"></i>&nbsp;Save</button>');
	// var cancelBtn = $('<button id="form-button-cancel" class="fm-button btn-large"><i class="fa fa-user"></i>&nbsp;Cancel</button>');
	// cancelBtn.click(function(){
	// 	var closeBtn = $('.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-icon-only.ui-dialog-titlebar-close');

	// 	if(closeBtn.length)
	// 		closeBtn.click();
	// 	else
	// 		history.back();
	// 	return false;
	// });
	// $('#save-button').replaceWith(newSaveBtn);
	// $('#save-and-go-back-button').parent().append(cancelBtn);

	// $('#status_display_as_box').text('Aktivasi User');

	// if(window.gcConf.state == 'Add')
	// {
	// 	$('#field-status').val('Enabled').trigger('change').hide().after('<b style="line-height: 25px;">Enabled</b>');
	// 	//console.log($('#field-status').val())
	// }
	// $('#form-button-cancel').unbind('click').click(function(){
	// 		$('.frm-user').clearForm();
	// 	return false;
	// });
	// var closeFrmBtn = $('<a id="backTo" title="Tutup" href="javascript:;"><i class="fa fa-times"></i></a>');
	// closeFrmBtn.click(function(){
	// 	document.location = '<?php echo base_url()?>system_configuration/users/';
	// });
	// closeFrmBtn.css({
	// 	padding : '2px 7px',
	// 	border  : 'solid 1px #ccc',
	// 	position : 'absolute',
	// 	margin : '0px 11px 0px 0px',
	// 	right : '0',
	// 	'border-radius' : '4px',
	// 	'z-index' : '3',
	// 	background : '#ddd'
	// });
	// $('.crud-form').prepend(closeFrmBtn);
	//console.log('here')

	//console.log(gcConf.state);

	// EXCLUDE NIP ALREDY REGISTERED
	if(gcConf.state == 'Add')
	{
		var nip_list_exist = <?php echo json_encode($nip_list_exist)?>;
		$('#field-nip option').each(function(){
			if($.inArray(this.value,nip_list_exist) >= 0)
				$(this).remove();
		});
		//console.log(nip_list_exist);
		$('#field-status').val('Aktif').trigger('change');
	}
	var ckStatus = '<input type="checkbox" id="ckStatus" />&nbsp;<span id="ckText"></span>';
	$('#field-status').after(ckStatus);

	$('#field-status').hide();
	var status_aktif = $('#field-status').val()=='Aktif';

	//console.log($('#field-status').val())
	setTimeout(function(){
		if(status_aktif)
		{
			$('#ckStatus').attr('checked',true);
			$('#ckText').text('Aktif');
		}
		else
		{
			$('#ckText').text('Inaktif');
			$('#field-status').val('Inaktif').trigger('change');
		}

		$('#ckStatus').click(function(){
			var status = this.checked ? 'Aktif' : 'Inaktif';
			//console.log(status)
			$('#field-status').val(status).trigger('change');
			$('#ckText').text(status);
		});
	},100);

	$('#field-nip option:first').text('-- Pilih NIP --');
	$('#field-id_group option:first').text('-- Pilih Group --');
});
</script>